﻿<!-- #Include File="../Include/Admin_Onlogin.asp" -->
<%
Data_Name = "{prefix}CopyFrom"
strFileName = "Admin_CopyFrom.asp"
Dim sqlAuth, rsAuth, PurviewID
sqlAuth = "Select AuthID From Admin_Auth Where href='Admin/" & strFileName & "?ChannelID="&ChannelID&"' Order By sort Asc,AuthID Asc"
Call Exec(rsAuth,sqlAuth,2)
If rsAuth.BOF And rsAuth.EOF Then
	PurviewID = 0
Else
	PurviewID = rsAuth(0)
	CheckPurview PurviewID,0
End If
rsAuth.Close
Set rsAuth = Nothing
Select Case Action
Case "Add"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Add' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call AddFrom()
Case "SaveAdd"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Insert' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveAdd()
Case "Modify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Edit' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Modify()
Case "SaveModify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveModify()
Case "Update"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Update()
Case "Del"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='CopyFrom/Del' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Del()
Case Else
    Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ChannelID = Code_CLng(Trim(Code_Form("ChannelID")))
		Sql = "Select * From ["&Data_Name&"]"
		If ChannelID<>0 Then
			Sql = Sql & " Where ChannelID=" & ChannelID & ""
		End If
		Sql = Sql & " Order By ID Desc"
		Call Exe_Conn(Rs,Sql,1)
		i = 0
		If Rs.BOF And Rs.EOF Then
			data = ""
		Else
			If Request("Page") <> "" Then
				CurrentPage = Code_CLng(Request("Page"))
			Else
				CurrentPage = 1
			End If
			MaxPerPage = Code_CLng(Trim(Request("limit")))
			If MaxPerPage <= 0 Then MaxPerPage = 10
			totalPut = Rs.RecordCount
			If CurrentPage < 1 Then
				CurrentPage = 1
			End If
			If (CurrentPage - 1) * MaxPerPage > totalPut Then
				If (totalPut Mod MaxPerPage) = 0 Then
					CurrentPage = totalPut \ MaxPerPage
				Else
					CurrentPage = totalPut \ MaxPerPage + 1
				End If
			End If
			If CurrentPage > 1 Then
				If (CurrentPage - 1) * MaxPerPage < totalPut Then
					Rs.Move (CurrentPage - 1) * MaxPerPage
				Else
					CurrentPage = 1
				End If
			End If
			Do While Not Rs.Eof
				If rs("ChannelID") > 0 Then
					sqlChannel = "select * from Channel where ChannelID=" & Code_CLng(rs("ChannelID"))
					Call Exec(rsChannel,sqlChannel,2)
					If rsChannel.BOF And rsChannel.EOF Then
						ChannelTit = ""
						rsChannel.Close
						Set rsChannel = Nothing
					Else
						ChannelTit = ToUnicode(Code_Html(rsChannel("ChannelTit"),1,0))
						rsChannel.Close
						Set rsChannel = Nothing
					End If
				End If
				If i=0 Then
					data = data & "{""id"":"&Rs("id")&",""SourceName"":"""&ToUnicode(Rs("SourceName"))&""",""SourceUrl"":"""&Rs("SourceUrl")&""",""ChannelName"":"""&ChannelTit&""",""ChannelID"":"&Rs("ChannelID")&"}"
				Else
					data = data & ",{""id"":"&Rs("id")&",""SourceName"":"""&ToUnicode(Rs("SourceName"))&""",""SourceUrl"":"""&Rs("SourceUrl")&""",""ChannelName"":"""&ChannelTit&""",""ChannelID"":"&Rs("ChannelID")&"}"
				End If
				iCount = iCount + 1
				If iCount >= MaxPerPage Then Exit Do
				Rs.MoveNext
				i=i+1
			Loop
			Rs.Close
		End If
		If totalPut = 0 Then
			Response.Write "{""code"":201,""msg"":""\u65e0\u6570\u636e""}" & vbCrLf
		Else
			Response.Write "{""code"":0,""msg"":""\u83b7\u53d6\u6210\u529f!"",""count"":"&totalPut&",""data"":["&data&"],""rel"":1}" & vbCrLf
		End If
		Response.End()
	Else
		Response.Write "<!DOCTYPE html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<title>来源管理</title>" & vbCrlf
		Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
		Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
		Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
		Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
		Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
		Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
		Response.Write "</head>" & vbCrlf
		Response.Write "<body>" & vbCrlf
		Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrLf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrLf
		Response.Write "        <legend>来源列表</legend>" & vbCrLf
		Response.Write "    </fieldset>" & vbCrLf
		Response.Write "    <table class=""layui-table"" id=""list"" lay-filter=""list""></table>" & vbCrLf
		Response.Write "</div>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""action"">" & vbCrLf
		Response.Write "    <a href=""?Action=Modify&ChannelID={{d.ChannelID}}&ID={{d.id}}"" class=""layui-btn layui-btn-xs""><i class=""fa fa-edit""></i> 编辑</a>" & vbCrLf
		Response.Write "    <a class=""layui-btn layui-btn-xs layui-btn-danger"" lay-event=""del""><i class=""fa fa-trash-o""></i> 删除</a>" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""SourceUrl"">" & vbCrLf
		Response.Write "    <a href=""{{d.SourceUrl}}"" target=""_blank"">{{d.SourceUrl}}</a>" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type=""text/html"" id=""topBtn"">" & vbCrlf
		Response.Write "    <a href=""?Action=Add&ChannelID=" & ChannelID & """ class=""layui-btn layui-btn-sm""><i class=""fa fa-plus""></i> 添加来源</a>" & vbCrlf
		Response.Write "    <button type=""button"" class=""layui-btn layui-btn-danger layui-btn-sm"" id=""delAll""><i class=""fa fa-trash-o""></i> 批量删除</button>" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "<script>" & vbCrLf
		Response.Write "    layui.use('table', function() {" & vbCrLf
		Response.Write "        var table = layui.table, $ = layui.jquery;" & vbCrLf
		Response.Write "        var tableIn=table.render({" & vbCrLf
		Response.Write "            id: 'content'," & vbCrlf
		Response.Write "            elem: '#list'," & vbCrLf
		Response.Write "            url: '?Action=Main'," & vbCrLf
		Response.Write "            method: 'post'," & vbCrLf
		Response.Write "            where: {//设定异步数据接口的参数" & vbCrLf
		Response.Write "                ChannelID: '"&ChannelID&"'" & vbCrLf
		Response.Write "            }," & vbCrLf
		Response.Write "            toolbar: '#topBtn'," & vbCrlf
		Response.Write "            cellMinWidth: 80," & vbCrLf
		Response.Write "            page:true," & vbCrLf
		Response.Write "            cols: [[" & vbCrLf
		Response.Write "                {type: ""checkbox"", fixed: true}," & vbCrlf
		Response.Write "                {field: 'id', title: '编号', width:80, fixed: true}," & vbCrLf
		Response.Write "                {field: 'ChannelName', title: '所属模型', width: 100}," & vbCrLf
		Response.Write "                {field: 'SourceName', title: '来源名称', width: 150, edit: 'text'}," & vbCrLf
		Response.Write "                {field: 'SourceUrl', title: '来源链接', width: 300,templet: '#SourceUrl', edit: 'text'}," & vbCrLf
		Response.Write "                {title: '操作', width: 190, align: 'center', toolbar: '#action'}" & vbCrLf
		Response.Write "            ]]" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "        //监听单元格编辑" & vbCrlf
		Response.Write "        table.on('edit(list)',function(obj) {" & vbCrlf
		Response.Write "            var value = obj.value, data = obj.data, field = obj.field;" & vbCrlf
		Response.Write "            if (field=='SourceName' && value=='') {" & vbCrLf
		Response.Write "                layer.tips('来源名称不能为空',this,{tips: [1, '#000']});" & vbCrLf
		Response.Write "                return false;" & vbCrLf
		Response.Write "            }else if (field=='SourceUrl' && (value=='' || !/(^  #)|(^#)|(^  http(s*):\/\/[^\s]+\.[^\s]+)|(^http(s*):\/\/[^\s]+\.[^\s]+)/.test(value))) {" & vbCrLf
		Response.Write "                layer.tips('链接格式不正确',this,{tips: [1, '#000']});" & vbCrLf
		Response.Write "                return false;" & vbCrLf
		Response.Write "            }else{" & vbCrLf
		Response.Write "                $.ajax({" & vbCrLf
		Response.Write "                    type: 'post'," & vbCrLf
		Response.Write "                    url: '?Action=Update'," & vbCrLf
		Response.Write "                    data: {ID:data.id,field:field,value:value,ChannelID:'"&ChannelID&"'}," & vbCrLf
		Response.Write "                    dataType: 'json'," & vbCrLf
		Response.Write "                    success: function(res) {" & vbCrLf
		Response.Write "                        if (res.code == 1) {" & vbCrlf
		Response.Write "                            layer.msg(res.msg, {time: 1000, icon: 1}, function () {" & vbCrlf
		Response.Write "                                tableIn.reload({ where: {ChannelID:'"&ChannelID&"'} });" & vbCrlf
		Response.Write "                            });" & vbCrlf
		Response.Write "                        }else{" & vbCrlf
		Response.Write "                            layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                        }" & vbCrlf
		Response.Write "                    }" & vbCrLf
		Response.Write "                });" & vbCrLf
		Response.Write "            }" & vbCrLf
		Response.Write "        });" & vbCrlf
		Response.Write "        table.on('tool(list)', function(obj) {" & vbCrLf
		Response.Write "            var data = obj.data;" & vbCrLf
		Response.Write "            if(obj.event === 'del'){" & vbCrLf
		Response.Write "                    layer.confirm('你确定要删除该来源吗？', function(index){" & vbCrLf
		Response.Write "                    $.ajax({" & vbCrLf
		Response.Write "                        type: 'post'," & vbCrLf
		Response.Write "                        url: '?Action=Del'," & vbCrLf
		Response.Write "                        data: {id:data.id,ChannelID:'"&ChannelID&"'}," & vbCrLf
		Response.Write "                        dataType: 'json'," & vbCrLf
		Response.Write "                        success: function(res) {" & vbCrLf
		Response.Write "                            if (res.code == 1) {" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                                obj.del();" & vbCrLf
		Response.Write "                            }else{" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                            }" & vbCrLf
		Response.Write "                        }" & vbCrLf
		Response.Write "                    });" & vbCrLf
		Response.Write "                    layer.close(index);" & vbCrLf
		Response.Write "                });" & vbCrLf
		Response.Write "            }" & vbCrLf
		Response.Write "        });" & vbCrLf
		Response.Write "        $('body').on('click','#delAll',function() {" & vbCrlf
		Response.Write "            var checkStatus = table.checkStatus('content'); //content即为参数id设定的值" & vbCrlf
		Response.Write "            var ids = [];" & vbCrlf
		Response.Write "            $(checkStatus.data).each(function (i, o) {" & vbCrlf
		Response.Write "                ids.push(o.id);" & vbCrlf
		Response.Write "            });" & vbCrlf
		Response.Write "            if(ids.toString()=="""") {" & vbCrlf
		Response.Write "                layer.msg(""\u81f3\u5c11\u9009\u62e9\u4e00\u6761\u4fe1\u606f"",{time:1000,icon:2});" & vbCrlf
		Response.Write "            } else {" & vbCrlf
		Response.Write "                layer.confirm('确认要删除选中的来源吗？', {icon: 3}, function(index) {" & vbCrlf
		Response.Write "                    layer.close(index);" & vbCrlf
		Response.Write "                    var loading = layer.load(1, {shade: [0.1, '#fff']});" & vbCrlf
		Response.Write "                    $.ajax({" & vbCrLf
		Response.Write "                        type: 'post'," & vbCrLf
		Response.Write "                        url: '?Action=Del'," & vbCrLf
		Response.Write "                        data: {ID: ids.toString(),ChannelID:'"&ChannelID&"'}," & vbCrLf
		Response.Write "                        dataType: 'json'," & vbCrLf
		Response.Write "                        success: function(res) {" & vbCrLf
		Response.Write "                            layer.close(loading);" & vbCrLf
		Response.Write "                            if (res.code==1) {" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                                tableIn.reload({where:{ChannelID:'"&ChannelID&"'}});" & vbCrlf
		Response.Write "                            }else{" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                            }" & vbCrLf
		Response.Write "                        }" & vbCrLf
		Response.Write "                    });" & vbCrLf
		Response.Write "                });" & vbCrlf
		Response.Write "            }" & vbCrLf
		Response.Write "        })" & vbCrlf
		Response.Write "    });" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "</body>" & vbCrLf & "</html>"
	End If
End Sub

Sub AddFrom()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>来源管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	Response.Write "<form class='layui-form layui-form-pane' id='myform' name='myform' action='?Action=SaveAdd&ChannelID=" & ChannelID & "' method=post>" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>添加来源</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">来源名称：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""SourceName"" type=""text"" id=""SourceName"" size=""30"" maxlength=""255"" value="""" placeholder=""请输入来源名称"" lay-verify=""required"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">来源链接：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""SourceUrl"" type=""text"" id=""SourceUrl"" size=""30"" maxlength=""255"" value="""" placeholder=""请输入来源链接"" lay-verify=""url"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<input name=""ChannelID"" type=""hidden"" id=""ChannelID"" value=""" & ChannelID & """><input type=""hidden"" name=""Action"" value=""SaveAdd"">" & Submit_Layui("提交添加","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveAdd'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
End Sub

Sub Modify()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>来源管理</title>" & vbCrlf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrlf
	Response.Write "<body>" & vbCrlf
	id=Code_ID("id")
	sql="select top 1 * From ["&Data_Name&"] where id="&id
	Call Exe_Conn(rs,sql,3)
	if rs.eof Then
		rs.close
		Response.Write IsSuccess("来源ID（"&id&"）不存在！",AdminFolder & "/Admin/" & strFileName & "?ChannelID="&ChannelID&"")
		exit sub
	End If
	Response.Write "<form class='layui-form layui-form-pane' id='myform' name='myform' action='?Action=SaveModify&ChannelID=" & ChannelID & "&id=" & id & "' method=post>" & vbCrlf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>修改来源</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">来源名称：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""SourceName"" type=""text"" id=""SourceName"" size=""30"" maxlength=""255"" value=""" & rs("SourceName") & """ placeholder=""请输入来源名称"" lay-verify=""required"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">来源链接：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""SourceUrl"" type=""text"" id=""SourceUrl"" size=""30"" maxlength=""255"" value=""" & rs("SourceUrl") & """ placeholder=""请输入来源链接"" lay-verify=""url"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<input name=""ChannelID"" type=""hidden"" id=""ChannelID"" value=""" & rs("ChannelID") & """><input name=""ID"" type=""hidden"" id=""ID"" value=""" & ID & """><input type=""hidden"" name=""Action"" value=""SaveModify"">" & Submit_Layui("提交修改","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveModify'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	rs.close
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveAdd()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ChannelID=Trim(Request.Form("ChannelID"))
		SourceName=Trim(Request.Form("SourceName"))
		SourceUrl=Trim(Request.Form("SourceUrl"))
		If ChannelID="" Then
			Response.Write "{""code"":0,""msg"":""\u6240\u5c5e\u9891\u9053\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If SourceName = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u586b\u5199\u6765\u6e90\u540d\u79f0\uff01""}" & vbCrLf
			Response.End()
		End If
		If SourceUrl = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u586b\u5199\u6765\u6e90\u94fe\u63a5\uff01""}" & vbCrLf
			Response.End()
		End If
		If FoundErr=True Then Exit Sub
		ID = GetNewID(Data_Name, "ID")
		sql="select * From ["&Data_Name&"] where ChannelID=" & ChannelID & " and SourceName='" & SourceName & "'"
		Call Exe_Conn(rs,sql,3)
		If Not (rs.BOF And rs.EOF) Then
			Response.Write "{""code"":0,""msg"":""\u6570\u636e\u5e93\u4e2d\u5df2\u7ecf\u5b58\u5728\u6b64\u6765\u6e90\uff01""}" & vbCrLf
			Response.End()
			rs.Close
			Set rs = Nothing
			Exit Sub
		End If
		rs.addnew
		rs("ID")=ID
		rs("ChannelID")=ChannelID
		rs("SourceName")=SourceName
		rs("SourceUrl")=SourceUrl
		rs.update
		rs.close
		'Response.Write IsConfirm("来源添加成功！请点击确定，需要继续修改点击取消！",AdminFolder & "/Admin/" & strFileName & "?ChannelID="&ChannelID&"",AdminFolder & "/Admin/" & strFileName & "?Action=Add&ChannelID="&ChannelID&"")
		Response.Write "{""code"":1,""msg"":""\u6765\u6e90\u6dfb\u52a0\u6210\u529f\uff01"",""url"":""?ChannelID="&ChannelID&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		ID=Trim(Request.Form("ID"))
		ChannelID=Trim(Request.Form("ChannelID"))
		SourceName=Trim(Request.Form("SourceName"))
		SourceUrl=Trim(Request.Form("SourceUrl"))
		If ChannelID="" Then
			Response.Write "{""code"":0,""msg"":""\u6240\u5c5e\u9891\u9053\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		If SourceName = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u586b\u5199\u6765\u6e90\u540d\u79f0\uff01""}" & vbCrLf
			Response.End()
		End If
		If SourceUrl = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u586b\u5199\u6765\u6e90\u94fe\u63a5\uff01""}" & vbCrLf
			Response.End()
		End If
		If FoundErr=True Then Exit Sub
		sql="select top 1 * From ["&Data_Name&"] where ID="&ID
		Call Exe_Conn(rs,sql,3)
		if rs.eof Then
			rs.close
			Response.Write "{""code"":0,""msg"":""\u6765\u6e90ID\uff08"&ID&"\uff09\u4e0d\u5b58\u5728\uff01""}" & vbCrLf
			Response.End()
			Exit Sub
		End If
		rs("ChannelID")=ChannelID
		rs("SourceName")=SourceName
		rs("SourceUrl")=SourceUrl
		rs.update
		rs.close
		'Response.Write IsConfirm("来源编辑成功！请点击确定，需要继续修改点击取消！",AdminFolder & "/Admin/" & strFileName & "?ChannelID="&ChannelID&"",AdminFolder & "/Admin/" & strFileName & "?Action=Modify&ChannelID="&ChannelID&"&id="&ID&"")
		Response.Write "{""code"":1,""msg"":""\u6765\u6e90\u7f16\u8f91\u6210\u529f\uff01"",""url"":""?ChannelID="&ChannelID&"""}" & vbCrLf
		Response.End()
		Exit Sub
	End If
End Sub

Sub Update()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim ID
		ID = Trim(Code_Form("ID"))
		field = Trim(Code_Form("field"))
		value = Trim(Code_Form("value"))
		If ID = "" Then
			Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u8981\u5220\u9664\u7684\u6765\u6e90ID\uff01"",""code"":0}"
			Response.End()
		End If
		Call Exec("","Update ["&Data_Name&"] Set "&field&"='"&value&"' where ID=" & ID,0)
		Response.Write "{""msg"":""\u7f16\u8f91\u6210\u529f\uff01"",""code"":1}"
		Response.End()
	End If
End Sub

Sub Del()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim ID
		ID = Trim(Code_Form("ID"))
		If ID = "" Then
			Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u8981\u5220\u9664\u7684\u6765\u6e90ID\uff01"",""code"":0}"
			Response.End()
		End If
		If InStr(ID, ",") > 0 Then
			Call Exec("","delete From ["&Data_Name&"] where ID in (" & ID & ")",0)
		Else
			Call Exec("","delete From ["&Data_Name&"] where ID=" & ID,0)
		End If
		'Response.Write IsSuccess("成功删除来源ID（"&ID&"）！",AdminFolder & "/Admin/" & strFileName & "?ChannelID="&ChannelID&"")
		Response.Write "{""msg"":""\u6210\u529f\u5220\u9664\u6765\u6e90ID\uff08"&ID&"\uff09\uff01"",""code"":1}"
		Response.End()
	End If
End Sub
%>